package demo.database.H2.D01_功能测试;


import java.sql.Connection;

import javax.sql.DataSource;

import org.h2.jdbcx.JdbcConnectionPool;

import com.titan.core.utils.db.DBUtils;
import com.titan.core.utils.db.DataSourceUtils;
import com.titan.core.utils.debug.Timer;
import com.titan.core.utils.io.ConsoleUtils;

public class T01_使用Druid {
    private static void run() throws Exception {
        String url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"; 
        String username = "sa";
        String password = "";
        
        DataSource dataSource = DataSourceUtils.registerDataSource(null, null, "jdbc:h2:mem:zzz", null, null, 5, 100);
        
        Connection conn = null;
        try {
            conn = dataSource.getConnection();
            ConsoleUtils.log(conn);
        } finally {
            DBUtils.close(conn);
            DataSourceUtils.close(dataSource);
        }
    }


    public static void main(String[] args) {
        Timer timer = Timer.$();
        try {
            run();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            timer.print();
        }
    }
}
